<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<div class="nav">
    <ul>
        <li>产品管理</li>
        <li>/</li>
        <li>添加产品</li>
    </ul>
</div>
<div>
    <form id="product-add-form">
        <p><input type="hidden" name="solutionImg" id="img"></p>
        <p>产品标题:<input type="text" name="productTitle" id="productTitle"></p>
        <p>产品描述: <textarea name="productDesc" id="productDesc" style="width: 700px;"></textarea></p>
        <p>产品图片:<input name="file" type="file" id="file"/>
            <input name="Token" type="hidden" id="Token"
                   value="68gl3i8ak1kj495d92p76ri37iaork9l:1EBWt6slqN4v0mdjtTTQcBec6MY=:eyJkZWFkbGluZSI6MTY2MTE3MjcyOCwiYWN0aW9uIjoiZ2V0IiwidWlkIjoxNzc4MiwiYWlkIjoiMzMwMjYiLCJmcm9tIjoiZmlsZSJ9"/>
            <input type="button" id="btn" onclick="upLoadPicture()" value="上传"/></p>
        <div id="img-box"></div>
        <p>产品网址:<input name="productHref" id="productHref" type="text"></p>
        <p>类别描述:<input name="typeDesc" id="typeDesc" type="text"></p>
        <p class="btn-box">
            <input type="button" onclick="doIt()" value="提交">
            <input type="reset" value="重填">
        </p>
    </form>
</div>
<script>
    tinymce.init({
        selector: '#productDesc', //容器，可使用css选择器
        language: 'zh_CN', //调用放在langs文件夹内的语言包
        toolbar: true, //工具栏
        menubar: true, //菜单栏
        branding: false, //右下角技术支持
        inline: false, //开启内联模式
        elementpath: false,
        min_height: 400, //最小高度
        height: 800, //高度
        skin: 'oxide',
        toolbar_sticky: true,
        visualchars_default_state: true, //显示不可见字符
        image_caption: true,
        paste_data_images: true,
        relative_urls: false,
        // remove_script_host : false,
        removed_menuitems: 'newdocument', //清除“文件”菜单
        plugins: "lists,hr,advlist,anchor,autolink,autoresize,charmap,code,codesample,emoticons,fullscreen,image,media,insertdatetime,link,pagebreak,paste,preview,print,searchreplace,table,textcolor,toc,visualchars,wordcount",   //依赖lists插件
        toolbar: 'bullist numlist anchor charmap emoticons fullscreen hr image insertdatetime link media pagebreak paste preview print searchreplace textcolor wordcount',
        images_upload_url: 'a.php',
        setup: function (editor) {
            editor.on('change', function () {
                editor.save();
            });
        }
    });
</script>
<script>
    function doIt() {
        var solutionImg = $("#img").val();
        var productTitle = $("#productTitle").val();
        var productHref = $("#productHref").val();
        var typeDesc = $("#typeDesc").val();
        var productDesc = tinymce.activeEditor.getContent();
        $.post("/web/product", {
            op: "save",
            solutionImg: solutionImg,
            productTitle: productTitle,
            productHref: productHref,
            typeDesc: typeDesc,
            productDesc: productDesc
        }, function (data) {
            $("#content").load("product/product-list.html");
            alert("添加" + (data == '1' ? "成功" : "失败"));
        })
    }
</script>
</body>
</html>